// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "google/protobuf-expectation/expectation-eval.h"

#include <vector>

#include "google/protobuf-expectation/stubs/integral_types.h"
#include "glog/logging.h"
#include "google/protobuf-expectation/expectation.pb.h"
#include "google/protobuf-expectation/unittest.pb.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf-expectation/stubs/numbers.h"
#include "gtest/gtest.h"
#include "google/protobuf-expectation/stubs/mathlimits.h"

using std::string;
using std::vector;

using google::protobuf::Descriptor;
using google::protobuf::EnumDescriptor;
using google::protobuf::EnumValueDescriptor;

namespace google {
namespace protobuf_expectation {

template <typename E, typename P>
class EvaluateTestOf : public ::testing::Test {
 protected:
  EvaluateTestOf() {
  }

  void Log() {
    for (int i = 0; i < eval_results_.size(); ++i) {
      VLOG(1) << "[" << i << "].field: " << eval_results_[i].field;
      VLOG(1) << "[" << i << "].expected: " << eval_results_[i].expected;
      VLOG(1) << "[" << i << "].actual: " << eval_results_[i].actual;
      VLOG(1) << "[" << i << "].success: " << eval_results_[i].success;
    }
    eval_results_.clear();
  }

  E expectation_;
  P proto_;
  vector<EvaluationResult> eval_results_;
};

typedef EvaluateTestOf<FieldExpectation, TestAllTypes>
EvaluateFieldExpectationWithTestAllTypes;
typedef EvaluateTestOf<ValueExpectation, TestAllTypes>
EvaluateValueExpectationWithTestAllTypes;
// We don't need any proto for evaluationg ValueExpectation for some test cases
// and the TestAllTypes here is a dummy parameter.
typedef EvaluateTestOf<ValueExpectation, TestAllTypes>
EvaluateValueExpectation;

TEST_F(EvaluateFieldExpectationWithTestAllTypes, NonexistentField) {
  expectation_.set_field_name("nonexistent_field");
  expectation_.set_has_field(false);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  expectation_.set_has_field(true);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes, FieldWithNoExpectation) {
  expectation_.set_field_name("optional_int32");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  expectation_.set_field_name("optional_nested_message");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  expectation_.set_field_name("repeated_int32");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  expectation_.set_field_name("repeated_nested_message");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes, HasInt32Field) {
  expectation_.set_field_name("optional_int32");
  expectation_.set_has_field(false);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  expectation_.set_has_field(true);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.set_optional_int32(123);
  expectation_.set_has_field(false);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  expectation_.set_has_field(true);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  // It's invalid to have field_size expectation.
  expectation_.mutable_field_size()->set_operator_(ValueExpectation::EQ);
  expectation_.mutable_field_size()->set_value("1");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes, HasMessageField) {
  expectation_.set_field_name("optional_nested_message");
  expectation_.set_has_field(false);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  expectation_.set_has_field(true);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.mutable_optional_nested_message()->set_bb(123);
  expectation_.set_has_field(false);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  expectation_.set_has_field(true);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  // It's invalid to have field_size expectation.
  expectation_.mutable_field_size()->set_operator_(ValueExpectation::EQ);
  expectation_.mutable_field_size()->set_value("1");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes, RepeatedInt32FieldSize) {
  expectation_.set_field_name("repeated_int32");
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.mutable_field_size()->set_operator_(ValueExpectation::EQ);
  expectation_.mutable_field_size()->set_value("2");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(1);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(2);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(3);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  // It's invalid to have has_field expectation.
  expectation_.set_has_field(true);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes, RepeatedMessageFieldSize) {
  expectation_.set_field_name("repeated_nested_message");
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.mutable_field_size()->set_operator_(ValueExpectation::EQ);
  expectation_.mutable_field_size()->set_value("2");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(1);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(2);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(3);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  // It's invalid to have has_field expectation.
  expectation_.set_has_field(true);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes, ValueExpectation) {
  expectation_.set_field_name("optional_int32");
  ValueExpectation* value_expectation =
      expectation_.mutable_value_expectation();
  // Proto field names of C++ reserved keywords are appended with "_".
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("123");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.set_optional_int32(123);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  value_expectation->set_operator_(ValueExpectation::NE);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes, MessageExpectation) {
  expectation_.set_field_name("optional_nested_message");
  FieldExpectation* field_expectation =
      expectation_.mutable_message_expectation()->add_field_expectation();
  field_expectation->set_field_name("bb");
  ValueExpectation* value_expectation =
      field_expectation->mutable_value_expectation();
  // Proto field names of C++ reserved keywords are appended with "_".
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("123");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.mutable_optional_nested_message()->set_bb(123);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  value_expectation->set_operator_(ValueExpectation::NE);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes,
       RepeatedValueExpectation_ForEach) {
  expectation_.set_field_name("repeated_int32");
  ValueExpectation* value_expectation =
      expectation_.mutable_repeated_value_expectation()->mutable_for_each()->
      mutable_value_expectation();
  // Proto field names of C++ reserved keywords are appended with "_".
  value_expectation->set_operator_(ValueExpectation::LT);
  value_expectation->set_value("2");
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(1);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(2);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(3);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes,
       RepeatedValueExpectation_Have) {
  expectation_.set_field_name("repeated_int32");
  ValueExpectation* value_expectation =
      expectation_.mutable_repeated_value_expectation()->add_have()->
      mutable_value_expectation();
  // Proto field names of C++ reserved keywords are appended with "_".
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("2");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(1);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(2);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(3);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes,
       RepeatedValueExpectation_HaveAtIndex) {
  expectation_.set_field_name("repeated_int32");
  RepeatedValueExpectation::Have* have_expectation =
      expectation_.mutable_repeated_value_expectation()->add_have();
  ValueExpectation* value_expectation =
      have_expectation->mutable_value_expectation();
  // Proto field names of C++ reserved keywords are appended with "_".
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("12");
  ValueExpectation* at_index_expectation =
      have_expectation->mutable_at_index();
  at_index_expectation->set_operator_(ValueExpectation::EQ);
  at_index_expectation->set_value("1");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(1);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(12);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(123);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  at_index_expectation->set_value("2");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes,
       RepeatedValueExpectation_DoNotHave) {
  expectation_.set_field_name("repeated_int32");
  ValueExpectation* value_expectation =
      expectation_.mutable_repeated_value_expectation()->add_do_not_have()->
      mutable_value_expectation();
  // Proto field names of C++ reserved keywords are appended with "_".
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("2");
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(1);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(2);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_int32(3);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes,
       RepeatedMessageExpectation_ForEach) {
  expectation_.set_field_name("repeated_nested_message");
  MessageExpectation* message_expectation =
      expectation_.mutable_repeated_message_expectation()->mutable_for_each()->
      mutable_message_expectation();
  FieldExpectation* field_expectation =
      message_expectation->add_field_expectation();
  field_expectation->set_field_name("bb");
  ValueExpectation* value_expectation =
      field_expectation->mutable_value_expectation();
  // Proto field names of C++ reserved keywords are appended with "_".
  value_expectation->set_operator_(ValueExpectation::LT);
  value_expectation->set_value("2");
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(1);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(2);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(3);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes,
       RepeatedMessageExpectation_Have) {
  expectation_.set_field_name("repeated_nested_message");
  MessageExpectation* message_expectation =
      expectation_.mutable_repeated_message_expectation()->add_have()->
      mutable_message_expectation();
  FieldExpectation* field_expectation =
      message_expectation->add_field_expectation();
  field_expectation->set_field_name("bb");
  ValueExpectation* value_expectation =
      field_expectation->mutable_value_expectation();
  // Proto field names of C++ reserved keywords are appended with "_".
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("2");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(1);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(2);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(3);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes,
       RepeatedMessageExpectation_HaveAtIndex) {
  expectation_.set_field_name("repeated_nested_message");
  RepeatedMessageExpectation::Have* have_expectation =
      expectation_.mutable_repeated_message_expectation()->add_have();
  MessageExpectation* message_expectation =
      have_expectation->mutable_message_expectation();
  FieldExpectation* field_expectation =
      message_expectation->add_field_expectation();
  field_expectation->set_field_name("bb");
  ValueExpectation* value_expectation =
      field_expectation->mutable_value_expectation();
  // Proto field names of C++ reserved keywords are appended with "_".
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("12");
  ValueExpectation* at_index_expectation =
      have_expectation->mutable_at_index();
  at_index_expectation->set_operator_(ValueExpectation::EQ);
  at_index_expectation->set_value("1");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(1);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(12);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(123);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  at_index_expectation->set_value("2");
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateFieldExpectationWithTestAllTypes,
       RepeatedMessageExpectation_DoNotHave) {
  expectation_.set_field_name("repeated_nested_message");
  MessageExpectation* message_expectation =
      expectation_.mutable_repeated_message_expectation()->add_do_not_have()->
      mutable_message_expectation();
  FieldExpectation* field_expectation =
      message_expectation->add_field_expectation();
  field_expectation->set_field_name("bb");
  ValueExpectation* value_expectation =
      field_expectation->mutable_value_expectation();
  // Proto field names of C++ reserved keywords are appended with "_".
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("2");
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(1);
  EXPECT_TRUE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(2);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
  proto_.add_repeated_nested_message()->set_bb(3);
  EXPECT_FALSE(Evaluate(expectation_, proto_, &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectationWithTestAllTypes, FieldIndex) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("1");
  const Descriptor* descriptor = proto_.GetDescriptor();
  // It's invalid to evaluate a singular field with index != -1.
  proto_.Clear();
  proto_.set_optional_bool(true);
  EXPECT_FALSE(Evaluate(expectation_, proto_,
                        descriptor->FindFieldByName("optional_bool"), 0,
                        &eval_results_));
  Log();
  // Test singular fields with index -1.
  proto_.set_optional_bool(true);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("optional_bool"), -1,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.set_optional_int32(1);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("optional_int32"), -1,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.set_optional_uint32(1);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("optional_uint32"), -1,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.set_optional_int64(1LL);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("optional_int64"), -1,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.set_optional_uint64(1ULL);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("optional_uint64"), -1,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.set_optional_float(1.0f);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("optional_float"), -1,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.set_optional_double(1.0);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("optional_double"), -1,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.set_optional_string("1");
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("optional_string"), -1,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.set_optional_nested_enum(TestAllTypes::FOO);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("optional_nested_enum"), -1,
                       &eval_results_));
  Log();
  // It's invalid to evaluate a message field.
  proto_.Clear();
  proto_.mutable_optional_nested_message()->set_bb(1);
  EXPECT_FALSE(Evaluate(expectation_, proto_,
                        descriptor->FindFieldByName("optional_nested_message"),
                        -1, &eval_results_));
  Log();

  // It's invalid to evaluate a singular field with index < 0.
  proto_.Clear();
  proto_.add_repeated_bool(true);
  EXPECT_FALSE(Evaluate(expectation_, proto_,
                        descriptor->FindFieldByName("repeated_bool"), -1,
                        &eval_results_));
  Log();
  // Test repeated fields with index 0.
  proto_.Clear();
  proto_.add_repeated_bool(true);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("repeated_bool"), 0,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.add_repeated_int32(1);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("repeated_int32"), 0,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.add_repeated_uint32(1);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("repeated_uint32"), 0,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.add_repeated_int64(1LL);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("repeated_int64"), 0,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.add_repeated_uint64(1ULL);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("repeated_uint64"), 0,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.add_repeated_float(1.0f);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("repeated_float"), 0,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.add_repeated_double(1.0);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("repeated_double"), 0,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.add_repeated_string("1");
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("repeated_string"), 0,
                       &eval_results_));
  Log();
  proto_.Clear();
  proto_.add_repeated_nested_enum(TestAllTypes::FOO);
  EXPECT_TRUE(Evaluate(expectation_, proto_,
                       descriptor->FindFieldByName("repeated_nested_enum"), 0,
                       &eval_results_));
  Log();
  // It's invalid to evaluate message fields.
  proto_.Clear();
  proto_.add_repeated_nested_message()->set_bb(1);
  EXPECT_FALSE(Evaluate(expectation_, proto_,
                        descriptor->FindFieldByName("repeated_nested_message"),
                        0, &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, BoolValue_Operators) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("true");
  EXPECT_TRUE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, false, &eval_results_));
  Log();
  expectation_.set_value("false");
  EXPECT_FALSE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, false, &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::NE);
  expectation_.set_value("true");
  EXPECT_FALSE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, false, &eval_results_));
  Log();
  expectation_.set_value("false");
  EXPECT_TRUE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, false, &eval_results_));
  Log();

  // ALMOST_EQ is invalid for bool values and it always returns false.
  expectation_.set_operator_(ValueExpectation::ALMOST_EQ);
  expectation_.set_value("true");
  EXPECT_FALSE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, false, &eval_results_));
  Log();
  expectation_.set_value("false");
  EXPECT_FALSE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, false, &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, BoolValue_CombineOperator) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::AND);
  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("true");
  value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::NE);
  value_expectation->set_value("false");
  // Combine operators are invalid for bool values and it always returns false.
  EXPECT_FALSE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, false, &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, BoolValue_Values) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  EXPECT_FALSE(Evaluate(expectation_, false, &eval_results_));
  Log();

  expectation_.set_value("TRUE");
  EXPECT_TRUE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, false, &eval_results_));
  Log();
  expectation_.set_value("True");
  EXPECT_TRUE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, false, &eval_results_));
  Log();
  expectation_.set_value("1");
  EXPECT_TRUE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, false, &eval_results_));
  Log();
  expectation_.set_value("FALSE");
  EXPECT_FALSE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, false, &eval_results_));
  Log();
  expectation_.set_value("False");
  EXPECT_FALSE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, false, &eval_results_));
  Log();
  expectation_.set_value("0");
  EXPECT_FALSE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, false, &eval_results_));
  Log();

  expectation_.set_value("invalid boolean value");
  EXPECT_FALSE(Evaluate(expectation_, true, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, false, &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, BoolValue_InvalidExpectation) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::NE);
  // Missing value field.
  EXPECT_FALSE(Evaluate(expectation_, true, &eval_results_));
  Log();
  expectation_.set_value("false");
  EXPECT_TRUE(Evaluate(expectation_, true, &eval_results_));
  // Having unnecessary value_expectation field.
  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::NE);
  value_expectation->set_value("false");
  EXPECT_FALSE(Evaluate(expectation_, true, &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, Int32Value_Operators) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("32");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(32), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(23), &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::NE);
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(23), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(32), &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::LE);
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(31), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(32), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(33), &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::LT);
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(31), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(32), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(33), &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::GE);
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(31), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(32), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(33), &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::GT);
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(31), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(32), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(33), &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::ALMOST_EQ);
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(31), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(32), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(33), &eval_results_));
  Log();

  // FULL_MATCH_RE is invalid for int32 values and it always returns false.
  expectation_.set_operator_(ValueExpectation::FULL_MATCH_RE);
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(32), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(23), &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, Int32Value_Values) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("-2147483649");  // (int32)0x80000000 - 1
  EXPECT_FALSE(Evaluate(expectation_, kint32max, &eval_results_));
  Log();
  expectation_.set_value("-2147483648");  // (int32)0x80000000
  EXPECT_TRUE(Evaluate(expectation_, kint32min, &eval_results_));
  Log();
  expectation_.set_value("-1");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(-1), &eval_results_));
  Log();
  expectation_.set_value("0");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(0), &eval_results_));
  Log();
  expectation_.set_value("1");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(1), &eval_results_));
  Log();
  expectation_.set_value("2147483647");  // 0x7fffffff
  EXPECT_TRUE(Evaluate(expectation_, kint32max, &eval_results_));
  Log();
  expectation_.set_value("2147483648");  // 0x80000000
  EXPECT_FALSE(Evaluate(expectation_, kint32min, &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::ALMOST_EQ);
  expectation_.set_value("0");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(0), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(1), &eval_results_));
  Log();
  expectation_.set_value("1000000000");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(1000000000),
                       &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(1000000001),
                        &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, Int32Value_InvalidExpectation) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  // Missing value field.
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(32), &eval_results_));
  Log();
  expectation_.set_value("32");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(32), &eval_results_));
  // Having unnecessary value_expectation field.
  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("32");
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(32), &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, UInt32Value_Values) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("-1");
  EXPECT_FALSE(Evaluate(expectation_, kuint32max, &eval_results_));
  Log();
  expectation_.set_value("0");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<uint32>(0), &eval_results_));
  Log();
  expectation_.set_value("1");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<uint32>(1), &eval_results_));
  Log();
  expectation_.set_value("2147483647");  // 0x7fffffff
  EXPECT_TRUE(Evaluate(expectation_, static_cast<uint32>(2147483647),
                       &eval_results_));
  Log();
  expectation_.set_value("2147483648");  // 0x80000000
  EXPECT_TRUE(Evaluate(expectation_, static_cast<uint32>(2147483648),
                       &eval_results_));
  Log();
  expectation_.set_value("4294967295");  // 0xffffffff
  EXPECT_TRUE(Evaluate(expectation_, kuint32max, &eval_results_));
  Log();
  expectation_.set_value("4294967296");  // 0x100000000
  EXPECT_FALSE(Evaluate(expectation_, static_cast<uint32>(0), &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::ALMOST_EQ);
  expectation_.set_value("0");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<uint32>(0), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<uint32>(1), &eval_results_));
  Log();
  expectation_.set_value("1000000000");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<uint32>(1000000000),
                       &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<uint32>(1000000001),
                        &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, Int64Value_Values) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  // (int64)0x8000000000000000 - 1
  expectation_.set_value("-9223372036854775809");
  EXPECT_FALSE(Evaluate(expectation_, kint64max, &eval_results_));
  Log();
  expectation_.set_value("-9223372036854775808");  // (int64)0x8000000000000000
  EXPECT_TRUE(Evaluate(expectation_, kint64min, &eval_results_));
  Log();
  expectation_.set_value("-1");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int64>(-1), &eval_results_));
  Log();
  expectation_.set_value("0");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int64>(0), &eval_results_));
  Log();
  expectation_.set_value("1");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int64>(1), &eval_results_));
  Log();
  expectation_.set_value("9223372036854775807");  // 0x7fffffffffffffff
  EXPECT_TRUE(Evaluate(expectation_, kint64max, &eval_results_));
  Log();
  expectation_.set_value("9223372036854775808");  // 0x8000000000000000
  EXPECT_FALSE(Evaluate(expectation_, kint64min, &eval_results_));
  Log();
  expectation_.set_value("18446744073709551615");  // (uint64)0xffffffffffffffff
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int64>(-1), &eval_results_));
  Log();
  expectation_.set_value("18446744073709551616");  // 0x10000000000000000
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int64>(0), &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::ALMOST_EQ);
  expectation_.set_value("0");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int64>(0), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int64>(1), &eval_results_));
  Log();
  expectation_.set_value("1000000000000000000");
  EXPECT_TRUE(Evaluate(expectation_,
                       static_cast<int64>(1000000000000000000LL),
                       &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_,
                        static_cast<int64>(1000000000000000001LL),
                        &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, UInt64Value_Values) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("-1");
  EXPECT_FALSE(Evaluate(expectation_, kuint64max, &eval_results_));
  Log();
  expectation_.set_value("0");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<uint64>(0), &eval_results_));
  Log();
  expectation_.set_value("1");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<uint64>(1), &eval_results_));
  Log();
  expectation_.set_value("9223372036854775807");  // 0x7fffffffffffffff
  EXPECT_TRUE(Evaluate(expectation_,
                       static_cast<uint64>(9223372036854775807LL),
                       &eval_results_));
  Log();
  expectation_.set_value("9223372036854775808");  // 0x8000000000000000
  EXPECT_TRUE(Evaluate(expectation_,
                       static_cast<uint64>(9223372036854775808ULL),
                       &eval_results_));
  Log();
  expectation_.set_value("18446744073709551615");  // (uint64)0xffffffffffffffff
  EXPECT_TRUE(Evaluate(expectation_, kuint64max, &eval_results_));
  Log();
  expectation_.set_value("18446744073709551616");  // 0x10000000000000000
  EXPECT_FALSE(Evaluate(expectation_, static_cast<uint64>(0), &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::ALMOST_EQ);
  expectation_.set_value("0");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<uint64>(0), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<uint64>(1), &eval_results_));
  Log();
  expectation_.set_value("10000000000000000000");
  EXPECT_TRUE(Evaluate(expectation_,
                       static_cast<uint64>(10000000000000000000ULL),
                       &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_,
                        static_cast<uint64>(10000000000000000001ULL),
                        &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, FloatValue) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value(SimpleFtoa(MathLimits<float>::kMin));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<float>::kMin, &eval_results_));
  Log();
  expectation_.set_value(SimpleFtoa(MathLimits<float>::kNegMin));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<float>::kNegMin,
                       &eval_results_));
  Log();
  expectation_.set_value("0");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<float>(0.0f),
                       &eval_results_));
  Log();
  expectation_.set_value(SimpleFtoa(MathLimits<float>::kPosMin));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<float>::kPosMin,
                       &eval_results_));
  Log();
  expectation_.set_value(SimpleFtoa(MathLimits<float>::kMax));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<float>::kMax, &eval_results_));
  Log();

  // A float value < kMin is parsed to be -HUGE_VALF, which is probably
  // less than kMin.
  expectation_.set_operator_(ValueExpectation::GT);
  expectation_.set_value(
      SimpleDtoa(static_cast<double>(MathLimits<float>::kMin) * 2.0));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<float>::kMin,
                       &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::LE);
  expectation_.set_value(SimpleDtoa(MathLimits<double>::kNegMin));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<float>::kNegMin,
                       &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::GE);
  expectation_.set_value(SimpleDtoa(MathLimits<double>::kPosMin));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<float>::kPosMin,
                       &eval_results_));
  Log();
  // A float value > kMax is parsed to be HUGE_VALF, which is probably
  // greater than kMax.
  expectation_.set_operator_(ValueExpectation::LT);
  expectation_.set_value(
      SimpleDtoa(static_cast<double>(MathLimits<float>::kMax) * 2.0));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<float>::kMax,
                       &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::ALMOST_EQ);
  expectation_.set_value("0.0");
  EXPECT_FALSE(Evaluate(expectation_, static_cast<float>(-0.00001f),
                        &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<float>(-0.000000001f),
                       &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<float>::kNegMin,
                       &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<float>(0.0f), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<float>::kPosMin,
                       &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<float>(0.000000001f),
                       &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<float>(0.00001f),
                        &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, DoubleValue) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value(SimpleDtoa(MathLimits<double>::kMin));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<double>::kMin, &eval_results_));
  Log();
  expectation_.set_value(SimpleDtoa(MathLimits<double>::kNegMin));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<double>::kNegMin,
                       &eval_results_));
  Log();
  expectation_.set_value("0");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<double>(0.0f),
                       &eval_results_));
  Log();
  expectation_.set_value(SimpleDtoa(MathLimits<double>::kPosMin));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<double>::kPosMin,
                       &eval_results_));
  Log();
  expectation_.set_value(SimpleDtoa(MathLimits<double>::kMax));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<double>::kMax, &eval_results_));
  Log();

  // A double value < kMin is parsed to be -HUGE_VAL, which is probably
  // less than kMin.
  expectation_.set_operator_(ValueExpectation::GT);
  expectation_.set_value(
      "-10.0e+" + SimpleItoa(MathLimits<double>::kMax10Exp + 20));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<double>::kMin,
                       &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::LE);
  expectation_.set_value(
      "-10.0e" + SimpleItoa(MathLimits<double>::kMin10Exp - 20));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<double>::kNegMin,
                       &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::GE);
  expectation_.set_value(
      "10.0e" + SimpleItoa(MathLimits<double>::kMin10Exp - 20));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<double>::kPosMin,
                       &eval_results_));
  Log();
  // A double value > kMax is parsed to be HUGE_VAL, which is probably
  // greater than kMax.
  expectation_.set_operator_(ValueExpectation::LT);
  expectation_.set_value(
      "10.0e+" + SimpleItoa(MathLimits<double>::kMax10Exp + 20));
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<double>::kMax,
                       &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::ALMOST_EQ);
  expectation_.set_value("0.0");
  EXPECT_FALSE(Evaluate(expectation_, static_cast<double>(-0.00001f),
                        &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<double>(-0.00000000000000001f),
                       &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<double>::kNegMin,
                       &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<double>(0.0f),
                       &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, MathLimits<double>::kPosMin,
                       &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<double>(0.00000000000000001f),
                       &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<double>(0.00001f),
                        &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, StringValue_Operators) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("foo");
  EXPECT_TRUE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, "bar", &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::NE);
  EXPECT_FALSE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, "bar", &eval_results_));
  Log();

  // ALMOST_EQ is invalid for string values and it always returns false.
  expectation_.set_operator_(ValueExpectation::ALMOST_EQ);
  EXPECT_FALSE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, "bar", &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::FULL_MATCH_RE);
  expectation_.set_value("fo*");
  EXPECT_TRUE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, "foot", &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::PARTIAL_MATCH_RE);
  expectation_.set_value("fo*");
  EXPECT_TRUE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, "foot", &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, "bar", &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::STRING_LENGTH);
  expectation_.clear_value();
  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("3");
  EXPECT_FALSE(Evaluate(expectation_, "fo", &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, "foot", &eval_results_));
  Log();

  // Case insensitive versions of string operators.
  expectation_.Clear();
  expectation_.set_case_sensitive(false);

  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("Foo");
  EXPECT_TRUE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, "bar", &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::NE);
  EXPECT_FALSE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, "bar", &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::FULL_MATCH_RE);
  expectation_.set_value("Fo*");
  EXPECT_TRUE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, "foot", &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::PARTIAL_MATCH_RE);
  expectation_.set_value("Fo*");
  EXPECT_TRUE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, "foot", &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, "bar", &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, StringValue_CombineOperator) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::AND);
  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::NE);
  value_expectation->set_value("foo");
  value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::NE);
  value_expectation->set_value("baz");
  EXPECT_FALSE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, "bar", &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, "baz", &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, StringValue_Values) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  EXPECT_FALSE(Evaluate(expectation_, "", &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::STRING_LENGTH);
  EXPECT_FALSE(Evaluate(expectation_, "", &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, StringValue_InvalidExpectations) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::FULL_MATCH_RE);
  // Missing value field.
  EXPECT_FALSE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  expectation_.set_value("fo*");
  EXPECT_TRUE(Evaluate(expectation_, "foo", &eval_results_));
  // Having unnecessary value_expectation field.
  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::FULL_MATCH_RE);
  value_expectation->set_value("fo*");
  EXPECT_FALSE(Evaluate(expectation_, "foo", &eval_results_));
  Log();

  expectation_.Clear();
  expectation_.set_operator_(ValueExpectation::PARTIAL_MATCH_RE);
  // Missing value field.
  EXPECT_FALSE(Evaluate(expectation_, "foot", &eval_results_));
  Log();
  expectation_.set_value("fo*");
  EXPECT_TRUE(Evaluate(expectation_, "foot", &eval_results_));
  // Having unnecessary value_expectation field.
  value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::PARTIAL_MATCH_RE);
  value_expectation->set_value("fo*");
  EXPECT_FALSE(Evaluate(expectation_, "foot", &eval_results_));
  Log();

  expectation_.Clear();
  expectation_.set_operator_(ValueExpectation::STRING_LENGTH);
  // Missing value_expectation field.
  EXPECT_FALSE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
  value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("3");
  EXPECT_TRUE(Evaluate(expectation_, "foo", &eval_results_));
  // Having unnecessary value field.
  expectation_.set_value("3");
  EXPECT_FALSE(Evaluate(expectation_, "foo", &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, EnumValue_ByName) {
  const EnumDescriptor* descriptor =
      TestAllTypes::descriptor()->FindEnumTypeByName("NestedEnum");
  const EnumValueDescriptor* foo = descriptor->FindValueByName("FOO");
  const EnumValueDescriptor* bar = descriptor->FindValueByName("BAR");
  const EnumValueDescriptor* baz = descriptor->FindValueByName("BAZ");
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("BAR");  // compare by name
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::NE);
  EXPECT_TRUE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, baz, &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::LE);
  EXPECT_TRUE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::LT);
  EXPECT_TRUE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::GE);
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, baz, &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::GT);
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, baz, &eval_results_));
  Log();

  // ALMOST_EQ is invalid for enum values and it always returns false.
  expectation_.set_operator_(ValueExpectation::ALMOST_EQ);
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("ZOO");  // compare by invalid name
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, EnumValue_RangeByNameWithCombineOperator) {
  const EnumDescriptor* descriptor =
      TestAllTypes::descriptor()->FindEnumTypeByName("NestedEnum");
  const EnumValueDescriptor* foo = descriptor->FindValueByName("FOO");
  const EnumValueDescriptor* bar = descriptor->FindValueByName("BAR");
  const EnumValueDescriptor* baz = descriptor->FindValueByName("BAZ");
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::AND);
  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::GT);
  value_expectation->set_value("FOO");
  value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::LT);
  value_expectation->set_value("BAZ");
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, EnumValue_ByNumber) {
  const EnumDescriptor* descriptor =
      TestAllTypes::descriptor()->FindEnumTypeByName("NestedEnum");
  const EnumValueDescriptor* foo = descriptor->FindValueByName("FOO");
  const EnumValueDescriptor* bar = descriptor->FindValueByName("BAR");
  const EnumValueDescriptor* baz = descriptor->FindValueByName("BAZ");
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("2");  // compare by number
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::NE);
  EXPECT_TRUE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, baz, &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::LE);
  EXPECT_TRUE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::LT);
  EXPECT_TRUE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::GE);
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, baz, &eval_results_));
  Log();
  expectation_.set_operator_(ValueExpectation::GT);
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, baz, &eval_results_));
  Log();

  // ALMOST_EQ is invalid for enum values and it always returns false.
  expectation_.set_operator_(ValueExpectation::ALMOST_EQ);
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();

  expectation_.set_operator_(ValueExpectation::EQ);
  expectation_.set_value("999");  // compare by invalid number
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, EnumValue_RangeByNumberWithCombineOperator) {
  const EnumDescriptor* descriptor =
      TestAllTypes::descriptor()->FindEnumTypeByName("NestedEnum");
  const EnumValueDescriptor* foo = descriptor->FindValueByName("FOO");
  const EnumValueDescriptor* bar = descriptor->FindValueByName("BAR");
  const EnumValueDescriptor* baz = descriptor->FindValueByName("BAZ");
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::AND);
  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::GT);
  value_expectation->set_value("1");
  value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::LT);
  value_expectation->set_value("3");
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, bar, &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, baz, &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, EnumValue_InvalidExpectation) {
  const EnumDescriptor* descriptor =
      TestAllTypes::descriptor()->FindEnumTypeByName("NestedEnum");
  const EnumValueDescriptor* foo = descriptor->FindValueByName("FOO");
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::LE);
  // Missing value field.
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
  expectation_.set_value("BAR");
  EXPECT_TRUE(Evaluate(expectation_, foo, &eval_results_));
  // Having unnecessary value_expectation field.
  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::LE);
  value_expectation->set_value("BAR");
  EXPECT_FALSE(Evaluate(expectation_, foo, &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, IsOperator) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::IS);
  // IS operator should have exactly one value_expectation.
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(0), &eval_results_));
  Log();

  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("123");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(123), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(321), &eval_results_));
  Log();

  // IS operator should have exactly one value_expectation.
  value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::NE);
  value_expectation->set_value("321");
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(123), &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, IsNotOperator) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::IS_NOT);
  // IS_NOT operator should have exactly one value_expectation.
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(0), &eval_results_));
  Log();

  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::EQ);
  value_expectation->set_value("123");
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(123), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(321), &eval_results_));
  Log();

  // IS_NOT operator should have exactly one value_expectation.
  value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::NE);
  value_expectation->set_value("321");
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(321), &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, AndOperator) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::AND);
  // AND operator should have one or more value_expectation.
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(0), &eval_results_));
  Log();

  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::GT);
  value_expectation->set_value("1");
  value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::LT);
  value_expectation->set_value("3");
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(0), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(1), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(2), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(3), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(4), &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, OrOperator) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::OR);
  // OR operator should have one or more value_expectation.
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(0), &eval_results_));
  Log();

  ValueExpectation* value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::LT);
  value_expectation->set_value("1");
  value_expectation = expectation_.add_value_expectation();
  value_expectation->set_operator_(ValueExpectation::GT);
  value_expectation->set_value("3");
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(0), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(1), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(2), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(3), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(4), &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, OrAndOperator) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::OR);
  ValueExpectation* value_expectation1 = expectation_.add_value_expectation();
  value_expectation1->set_operator_(ValueExpectation::AND);
  ValueExpectation* value_expectation2 =
      value_expectation1->add_value_expectation();
  value_expectation2->set_operator_(ValueExpectation::GE);
  value_expectation2->set_value("1");
  value_expectation2 = value_expectation1->add_value_expectation();
  value_expectation2->set_operator_(ValueExpectation::LT);
  value_expectation2->set_value("2");
  value_expectation1 = expectation_.add_value_expectation();
  value_expectation1->set_operator_(ValueExpectation::AND);
  value_expectation2 = value_expectation1->add_value_expectation();
  value_expectation2->set_operator_(ValueExpectation::GT);
  value_expectation2->set_value("4");
  value_expectation2 = value_expectation1->add_value_expectation();
  value_expectation2->set_operator_(ValueExpectation::LE);
  value_expectation2->set_value("5");

  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(0), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(1), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(2), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(3), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(4), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(5), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(6), &eval_results_));
  Log();
}

TEST_F(EvaluateValueExpectation, AndOrOperator) {
  // Proto field names of C++ reserved keywords are appended with "_".
  expectation_.set_operator_(ValueExpectation::AND);
  ValueExpectation* value_expectation1 =
      expectation_.add_value_expectation();
  value_expectation1->set_operator_(ValueExpectation::OR);
  ValueExpectation* value_expectation2 =
      value_expectation1->add_value_expectation();
  value_expectation2->set_operator_(ValueExpectation::LE);
  value_expectation2->set_value("1");
  value_expectation2 = value_expectation1->add_value_expectation();
  value_expectation2->set_operator_(ValueExpectation::GT);
  value_expectation2->set_value("2");
  value_expectation1 = expectation_.add_value_expectation();
  value_expectation1->set_operator_(ValueExpectation::OR);
  value_expectation2 = value_expectation1->add_value_expectation();
  value_expectation2->set_operator_(ValueExpectation::LT);
  value_expectation2->set_value("4");
  value_expectation2 = value_expectation1->add_value_expectation();
  value_expectation2->set_operator_(ValueExpectation::GE);
  value_expectation2->set_value("5");

  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(0), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(1), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(2), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(3), &eval_results_));
  Log();
  EXPECT_FALSE(Evaluate(expectation_, static_cast<int32>(4), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(5), &eval_results_));
  Log();
  EXPECT_TRUE(Evaluate(expectation_, static_cast<int32>(6), &eval_results_));
  Log();
}

}  // namespace protobuf_expectation
}  // namespace google
